package kiwi.core.services.search.solr.program.parser.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * User: Thomas Kurz
 * Date: 28.03.11
 * Time: 13:29
 */
public class Program extends ArrayList<Rule> {

	private Map<String,String> mapper = new HashMap<String,String>();
	/**
	 * returns internal solr name for rule name or name (if no rule with name defined)
	 * @param name
	 * @return
	 */
	public String getInternalName(String name) {
		String s = mapper.get(name);
		return s!=null ? s : name;
	}

	@Override
	public boolean add(Rule rule) {
		mapper.put(rule.getName(),rule.getInternalName());
		return super.add(rule);
	}
}
